<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="UTF-8">
		<title>登录</title>
		<link rel="stylesheet" type="text/css" href="../../css/public.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/login.css"/>
	</head>
	<body>
		<!-------------------login-------------------------->
		<div class="login">
			<form action="" id="form-login" method="post">
				<h1><img src="../../img/temp/logo2.png"></h1>
				<p></p>
				<div class="msg-warn hide"><b></b>公共场所不建议自动登录，以防账号丢失</div>
<!--				<p th:text="${msg}" style="color:red"></p>-->
				<p><input type="text" id="username" name="username" value="" placeholder="账号"></p>
				<p><input style="border:1px solid #dbdbdb; font-size: 20px;padding-left:10px; " type="password" id="password" name="password" value="" placeholder="密码"></p>
				<p><input  style=
								   "width:280px;
						            background-color: #C10000;
						            font-size: 20px;
						            border:none;
						            color:#fff;"
						            type="button"  name="" id="login" value="登  录"></p>
<!--				<p><input type="radio" name="" value="buyers"/>买家</p>-->
<!--				<p><input type="radio" name="" value="seller" />卖家</p>-->
				<p class="txt"><a class="" href="reg">免费注册</a><a href="forget">忘记密码？</a></p>
			</form>
		</div>
		
	</body>

	<script type="text/javascript" src="../../js/jquery-3.5.1.min.js"></script>
	<script type="text/javascript" src="../../js/sweetalert.min.js"></script>
	<script type="text/javascript">
		$(function () {
			$('#login').click(function () {
				// alert('ok');
				// //获取用户名和密码:
				// username = $('#username').val();
				// password = $('#password').val();

				// alert(rember);
				$.ajax({
					url: "/login",
					type: "POST", //提交方式
					data: $("#form-login").serialize(),
					dataType: "json",
					success: (function (json) {
						if (json.state == 200) {
							swal({
								title: '登录成功',
								icon: 'success'
							}).then(function () {
								location.href = 'index'
							})
						} else {
							// alert("密码错误")
							swal({
								title: '登陆失败',
								icon: 'warning',
								text: json.message,
								button: {
									text: "确认",
									value: true,
								}
							}).then(function (isok) {
								if (isok) {
									location.href = 'login'
								}
							})
						}
					})
				})
			})
		})



</script>
</html>
